﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace RitS.Physics
{
    class PhysicsBodyBase : IPhysicsBody
    {
        private const int DefaultTickTime = 10;

        public Point RelativeCenterMass { get; set; }
        public Vector Velocity { get; set; }
        public double Rotation { get; set; }
        public double Mass { get; set; }
        public Point Position { get; set; }

        public void ApplyForceTick(Vector force)
        {
            ApplyForceTick(force, DefaultTickTime);
        }

        public void ApplyForceTick(Vector force, int Ticks)
        {
            Vector newVelocity = Velocity + new Vector(Ticks * force.X / Mass, Ticks * force.Y / Mass);
            Velocity = newVelocity;
        }

        public void ApplyVelocityTick(int Ticks)
        {
            Position += Velocity * Ticks;
        }

        public void ApplyThrustTick(double thrust)
        {
            Vector force = new Vector();
            force.X = Math.Sin(Rotation) * thrust;
            force.Y = Math.Cos(Rotation) * thrust;
            
            ApplyForceTick(force);
        }

    }
}
